import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";

export default defineConfig({
  // base: "vite",
  transpileDependencies: true,
  plugins: [vue()],
  define: {
    "process.env": process.env
  },


  resolve: {
    // Vite路径别名配置
    alias: {
      "@": path.resolve("./src")
    },
    extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"]
  },
  // 配置前端服务地址和端口
  server: {
    host: "0.0.0.0",
    port: 8889,
    // 是否开启 https
    https: false,
    // 设置反向代理，跨域
    proxy: {
      "/zytapi": {
        // 后台地址
         target: "http://114.242.25.97:20167",//http://202.127.42.144:60011
        // target: "http://202.127.42.144:60011/api/newarchive/",
        changeOrigin: true,
        rewrite: path => path.replace(/^\/zytapi/, "")
      },
      '/oss-pdf': {
        target: 'https://jynlz-test.oss-cn-beijing.aliyuncs.com',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/oss-pdf/, '')
      },'/proxy-pdf': {
        target: 'https://mozilla.github.io',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/proxy-pdf/, ''),
      },
    }
  }
});
